package adke.models;

import adke.Util;

// model met twee controls voor het besturen van de lijn

public class ControlSet
{
    private Player owner;
    
    // keys
    private int leftKey, rightKey, powerKey;
    
    // 0 = links, 1 = rechts
    private int layout;
    
    public ControlSet(int left, int power, int right)
    {
        leftKey = left;
        rightKey = right;
        powerKey = power;
        
        layout = -1;
    }
    
    // shift, control en slash komen > 1 keer voor dus moeten we bepalen aan welke kant
    // we ze willen hebben
    public ControlSet(int left, int power, int right, int layout)
    {
        this(left, power, right);
        this.layout = layout;
    }
    
    public ControlSet(int[] keys)
    {
        this(keys[0], keys[2], keys[1]);
        
        // er is een layout-modifuier meegegeven
        if (keys.length == 4)
        {
            this.layout = keys[3];
        }
    }
    
    public void setOwner(Player player)
    {
        owner = player;
    }
    
    public Player getOwner()
    {
        return owner;
    }
    
    public int getLeftKey()
    {
        return leftKey;
    }
    
    public String getLeftKeyText()
    {
        return Util.keyToString(leftKey);
    }
    
    public String getRightKeyText()
    {
        return Util.keyToString(rightKey);
    }
    
    public String getPowerKeyText()
    {
        return Util.keyToString(powerKey);
    }
    
    public int getRightKey()
    {
        return rightKey;
    }
    
    public int getPowerKey()
    {
        return powerKey;
    }
    
    public boolean hasLayoutModifier()
    {
        return layout != -1;
    }
    
    public int getLayoutModifier()
    {
        return layout;
    }

    public boolean isPowerKey(int key)
    {
        return key == powerKey;
    }
    
    public boolean isLeftKey(int key)
    {
        return key == leftKey;
    }
    
    // true = left
//    public boolean isKey(int key, boolean leftRight, int modifier)
//    {
//        // left
//        if (leftRight)
//        {
//            
//        }
//        else
//        {
//            
//        }
//    }
    
    public boolean isRightKey(int key)
    {
        return key == rightKey;
    }
}
